package com.ly.common.core.condition;

import cn.hutool.core.util.ObjUtil;
import com.ly.common.core.constant.BaseConstant;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

/**
 * 微服务环境-条件
 *
 * @author luoyun
 */
public class ServiceCondition implements Condition {

    /**
     * 判断是否是微服务环境，单体true
     *
     * @param context
     * @param metadata
     * @return
     */
    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        Object object = context.getEnvironment().getProperty(BaseConstant.CLOUD_SERVER_KEY);
        return ObjUtil.isNull(object);
    }
}
